package com.zkthink.ceres.applet.homePage.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zkthink.base.R;
import com.zkthink.base.request.PageParams;
import com.zkthink.ceres.applet.authority.service.AppletMemberService;
import com.zkthink.ceres.applet.ceresStore.service.CeresStoreService;
import com.zkthink.ceres.applet.common.domin.PageDate;
import com.zkthink.ceres.applet.common.domin.vo.PageDateTypeIdVo;
import com.zkthink.ceres.applet.homePage.domain.vo.FindCategoryListPageVo;
import com.zkthink.ceres.applet.homePage.service.HomePageService;
import com.zkthink.ceres.applet.order.domain.vo.OrderListVo;
import com.zkthink.ceres.applet.order.domain.vo.OrderPageVo;
import com.zkthink.ceres.applet.server.domain.entity.AppletStoreServer;
import com.zkthink.ceres.applet.server.service.AppletServerService;
import com.zkthink.ceres.store.service.StoreService;
import com.zkthink.ceres.store.vo.HomePageStoreOrVehiclesVo;
import com.zkthink.ceres.store.vo.StoreOrVehiclesStatusVo;
import com.zkthink.clh.order.dto.CouponsPageDTO;
import com.zkthink.clh.order.entity.ChlCoupons;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author cmz
 * @Date 2024-05-08 10:23
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/applet/homePage")
@Api(value = "homePage", tags = "首页")
public class HomePageController {
    @Resource
    private HomePageService homePageService;
    @Resource
    private AppletServerService appletServerService;
    @Resource
    private CeresStoreService ceresStoreService;

    @Resource
    private AppletMemberService appletMemberService;

    @ApiOperation(value = "查询服务、产品分类列表", notes = "查询服务、产品分类列表")
    @GetMapping(value = "/findHomePageCategory")
    public R findHomePageCategory() {
        return homePageService.findHomePageCategory();
    }

    @ApiOperation(value = "分页查询服务或产品分类列表", notes = "分页查询服务或产品分类列表")
    @PostMapping(value = "/findCategoryList")
    public R findCategoryList(@RequestBody FindCategoryListPageVo findCategoryListPageVo) {
        return homePageService.findCategoryList(findCategoryListPageVo);
    }

    @ApiOperation(value = "产品分类列表", notes = "产品分类列表")
    @GetMapping(value = "/findHomeProductCategory")
    public R findHomeProductCategory() {
        return homePageService.findHomeProductCategory();
    }


    @ApiOperation(value = "查询服务或商品信息列表", notes = "查询服务信息列表")
    @PostMapping(value = "/findServerOrProduct")
    public R findServerOrProduct(@RequestBody PageDateTypeIdVo pageDateTypeIdVo) {
        return appletServerService.findServerOrProduct(pageDateTypeIdVo);
    }

    @ApiOperation(value = "查询推荐商品信息列表", notes = "查询推荐商品信息列表")
    @PostMapping(value = "/findRecoProduct")
    public R findRecoProduct(@RequestBody PageDate pageDate) {
        return appletServerService.findRecoProduct(pageDate);
    }

    @ApiOperation(value = "查询当前登录的账号门店或车辆信息", notes = "查询当前登录的账号门店或车辆信息")
    @GetMapping(value = "/findMyStoreOrVehicles")
    public R<HomePageStoreOrVehiclesVo> findMyStoreOrVehicles() {
        return ceresStoreService.findMyStoreOrVehicles();
    }

    @ApiOperation(value = "修改当前登录用户的门店或车辆的状态(0休息、1营业)", notes = "修改当前登录用户的门店或车辆的状态(0休息、1营业)")
    @PostMapping(value = "/updateMyStoreStatus")
    public R updateMyStoreStatus(@RequestBody StoreOrVehiclesStatusVo storeOrVehiclesStatusVo) {
        return ceresStoreService.updateMyStoreStatus(storeOrVehiclesStatusVo);
    }

    @ApiOperation(value = "查询我的订单", notes = "查询我的订单")
    @PostMapping(value = "/findMyOrders")
    public R<Page<OrderListVo>> findMyOrders(@RequestBody OrderPageVo pageDate) {
        return ceresStoreService.findMyOrders(pageDate);
    }

    @ApiOperation(value = "后台查询惠消费金", notes = "后台查询惠消费金")
    @PostMapping(value = "/findCoupons")
    public R<IPage<ChlCoupons>> findCoupons(@RequestBody PageParams<CouponsPageDTO> dto) {
        CouponsPageDTO model = dto.getModel();
        IPage page = dto.getPage();
        return R.success(appletMemberService.findCoupons(page, model));
    }

    @ApiOperation(value = "VIP列表", notes = "VIP列表")
    @GetMapping(value = "/selectVipList")
    public R findCoupons() {
        return R.success(appletMemberService.selectVip());
    }

    @ApiOperation(value = "购买VIP", notes = "购买VIP")
    @GetMapping("/buyVip")
    public R buyVip(@PathVariable String vipId) {
        return appletMemberService.buyVip(vipId);
    }

    @ApiOperation(value = "购买消费金", notes = "购买消费金")
    @GetMapping("/buyChlCoupons")
    public R buyChlCoupons(@PathVariable String chlCouponsId) {
        return appletMemberService.buyChlCoupons(chlCouponsId);
    }
    

}